/**
 * 
 */
package ma.hamada.swing;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JPanel;

import ma.hamada.controller.PuzzleController;
import ma.hamada.event.PuzzleChangedEvent;
import ma.hamada.view.PuzzleView;

/**
 * @author M.ABDELOUHAB
 *
 */
public class JFramePuzzleView extends PuzzleView implements ActionListener{
	
	private JFrame frame = null;
	private JPanel contentPane = null;

	public JFramePuzzleView(PuzzleController controller) {
		super(controller);
		buildFrame(controller);
	}
	
	private void buildFrame(PuzzleController controller) {
		frame = new JFrame("JAVA PUZZLE");
		contentPane = new JPanel(new GridLayout(4, 4,0,0));
		frame.setSize(400, 400);
		frame.setResizable(false);
		frame.setLocationRelativeTo(null);
		frame.add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.NORTH); 
		frame.add(contentPane,BorderLayout.CENTER);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
	}

	@Override
	public void display() {
		frame.setVisible(true);
	}

	@Override
	public void close() {
		frame.dispose();
	}

	/**
	 * @return the contentPane
	 */
	public JPanel getContentPane() {
		return contentPane;
	}

	/**
	 * @param contentPane the contentPane to set
	 */
	public void setContentPane(JPanel contentPane) {
		this.contentPane = contentPane;
	}

	@Override
	public void puzzleChanged(PuzzleChangedEvent event) {
		// TODO Auto-generated method stub
		
	}

}
